<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text">
<input type="button" value="添加文本" onclick="f1()">
<input type="button" value="添加图片" onclick="f2()">
<script>
  let i = document.querySelector("input");
  function f1(){
    let h = document.createElement("h1")
    h.innerText = i.value;
    document.body.append(h);
  }
  function f2(){
    let img = document.createElement("img")
    img.src = "https://w.wallhaven.cc/full/l3/wallhaven-l38eqq.jpg";
    document.body.append(img);
  }
</script>
</body>
</html>